﻿using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;

namespace Puppy.Scheduler
{
    public class HelloPersonService : ITransientDependency
    {
        private readonly IRepository<Person, Guid> _personRepository;

        public HelloPersonService(
            IRepository<Person, Guid> personRepository)
        {
            _personRepository = personRepository;
        }

        public async Task InsertPerson()
        {
            var douglas = new Person(Guid.NewGuid(), "Douglas", 42);
            douglas.Phones.Add(new Phone(douglas.Id, "123456789"));
            douglas.Phones.Add(new Phone(douglas.Id, "123456780", PhoneType.Home));

            await _personRepository.InsertAsync(douglas);
        }
    }
}
